package com.jgsu.farm.service.impl;

import com.jgsu.farm.entity.User;
import com.jgsu.farm.mapper.GeneralUserMapper;
import com.jgsu.farm.service.GeneralUserService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @program: farm-10-14-2019
 * @description: 普通用户service实现类
 * @author: Mr.zuo
 * @create: 2019-12-06 18:39
 **/
@Service
public class GeneralUserServiceImpl implements GeneralUserService {
    @Autowired
    GeneralUserMapper generalUserMapper;


    @Override
    public PageInfo<User> queryGeneral(Integer role, int page, int pagesize) {
        PageHelper.startPage(page, pagesize);
        List<User> users = generalUserMapper.selectList(role);
        PageInfo<User> pageInfoGenerUserList = new PageInfo<User>(users);
        return pageInfoGenerUserList;

    }

    @Override
    public void modifyGeneralMsg(User user) {
         generalUserMapper.updateGeneral(user);
    }

    @Override
    public int deleteGeneralByPhone(String phone) {
        int i = generalUserMapper.deleteGeneralByPhone(phone);
        return i;
    }
}
